package com.taxi.driver.module.main.mine.wallet.bill;

import android.content.Context;
import android.view.View;
import android.widget.RelativeLayout;

import com.qianxx.adapter.SuperAdapter;
import com.qianxx.adapter.internal.SuperViewHolder;
import com.taxi.driver.R;
import com.taxi.driver.module.vo.BillItemVO;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class BillRecordAdapter extends SuperAdapter<BillItemVO> {
    private SimpleDateFormat sf;

    public BillRecordAdapter(Context context) {
        super(context, new ArrayList<BillItemVO>(), R.layout.item_bill_record);
        sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    }

    @Override
    public void onBind(SuperViewHolder holder, int viewType, int position, BillItemVO item) {
        RelativeLayout rl = (RelativeLayout) holder.getView(R.id.rl);
        String date = sf.format(new Date(item.time));
        holder.setText(R.id.tv_date, date.substring(0, 10));
        if (position == 0) {
            rl.setVisibility(View.VISIBLE);
        } else {
            rl.setVisibility(View.GONE);
            String forwardDate = sf.format(new Date(mList.get(position - 1).time));
            if (date.substring(0, 10).equals(forwardDate.substring(0, 10))) {
                rl.setVisibility(View.GONE);
            } else {
                rl.setVisibility(View.VISIBLE);
            }
        }
        holder.setText(R.id.tv_project, item.remark);
        holder.setText(R.id.tv_fee, item.signedMoney);

        holder.setText(R.id.tv_time, date.substring(10));
    }
}
